#include <signal.h>
#include <iostream>

//把信号的注册封装到类中

class Serial
{
private:

public:
    Serial()
    {
        if(signal(SIGINT, reset_termio)==SIG_ERR)
            perror("signal(SIGINT)");
    }
    static void reset_termio(int signo)
    {
        std::cout<<"程序收到退出指令，退出，signo: "<<signo<<std::endl;
        exit(-1);
    }
};

int main()
{
    Serial serial;
    std::cout << "start" << std::endl;
    while(1);
    return 0;
}